package znbkListRdqh.paperAssembly;

import android.util.Log;

import com.lancoo.reviewsystem.utils.ToastUtils;
import com.lancoo.rxretrofitlibrary.http.HttpManager;
import com.lancoo.rxretrofitlibrary.listener.HttpOnNextListener;

import java.util.List;

import znbkListRdqh.fragment.WeekAscensionListFragment;
import znbkListRdqh.isNeedPaperAssembly.ILoadDateViewAssembly;
import znbkListRdqh.isNeedPaperAssembly.ILoadDatePresenterAssembly;

/**
 * Created by Administrator on 2018\4\19 0019.
 */

public class WeekAscensionMakePaperPresenter implements ILoadDatePresenterAssembly {

    private ILoadDateViewAssembly view;

    public WeekAscensionMakePaperPresenter(ILoadDateViewAssembly view) {
        this.view = (ILoadDateViewAssembly) view;
    }

    @Override
    public void getData() {

        HttpOnNextListener<List<WeekAscensionMakePaperResult>> httpOnNextListener = new HttpOnNextListener<List<WeekAscensionMakePaperResult>>() {
            @Override
            public void onNext(List<WeekAscensionMakePaperResult> weekAscensionMakePaperResult) {

                if(weekAscensionMakePaperResult.size()>0){
                    //需要组卷
//                    ToastUtils.showShort("组卷成功");
                    view.assemblyPaperSuccessed();
                }else{
                    //无需组卷
                    ToastUtils.showShort("当前所有知识点已经掌握");
                }
            }


            @Override
            public void onError(Throwable e) {
                super.onError(e);
                view.showNetError();
            }

            @Override
            public void onComplete() {
                super.onComplete();
                Log.d("TML","end: "+System.currentTimeMillis());
            }
        };

        WeekAscensionMakePaperApi api = new WeekAscensionMakePaperApi(httpOnNextListener, (WeekAscensionListFragment) view);
        HttpManager httpManager = HttpManager.getInstance();
        httpManager.doHttpDeal(api);
    }

}
